function [output_1,output_2,output_3,output_4] = runparallelcode_adaptive(input)

[f_xnext,f_dxn_dx,f_dxn_du,n,m,N,alphac,epsilon,baru,T,deltat,mu_e,mu_m,mu,r_lagrange_1,r_lagrange] = make_problem();
[bfu0,x_e,y_e,xearth,xmoon,yearth,ymoon,theta,r_LEO,r_LMO,G,B,map,p_0_x,p_0_y,v_0_x,v_0_y,x0,v_f]=make_hohmann();
[f_xN_bfu] = make_f_xN_bfu(f_xnext,n,m,N,x0);
[f_dgdu,f_g_new,f_gtil_new,f_bfx,f_dgdu_new] = make_f_g(f_xnext,f_dxn_dx,f_dxn_du,f_xN_bfu,n,m,N,x0,mu,r_LMO,v_f);

bfu = struct();% m*N=2*N 入力
bfx = struct();% n*N=4*N 状態
% angle = 345/360*8;
% impulse = 300+mod(input-1,8)*100;
% bfu0 = [impulse*cos(angle*pi/4);impulse*sin(angle*pi/4);zeros(m*N-2,1)];
% bfu0 = [3000;4000;zeros(m*N-2,1)];
bfu0 = zeros(m*N,1);
bfu0(2) = 800;

bfu(1).data = bfu0;
bfx(1).data = f_bfx(bfu(1).data);

% beta = 0.0;
% c_0 = 1.0;
% h = 0.0;

beta = 0.3;
% c_0 = 3.0;
h = 0.5;

% beta = 0.3;
% c_0 = 3.5;
% h = 0.5;

c_max = 2*(1+beta)/(1-beta);
% gamma = 0.995;
% gamma = 0.99;
% gamma = 0.95;
gamma = 0.95;

k = 1;
err = 1;
mmt = zeros(m*N,1);
convergence_text = 'n';

% convert_xy_vector
% plot(plot_x, plot_y, 'o', 'MarkerSize', 1, 'Color', 'r');
% hold on
% scatter(-mu, 0, 50, 'b', 'filled'); % 100 is the marker size
% scatter(1-mu, 0, 20, 'b', 'filled'); % 100 is the marker size
% xlim([-0.2, 1.2]);
% ylim([-0.5*(1+2*mu), 0.5*(1+2*mu)]);
% axis equal;
% 
% 
% pause(1)

while k<1000
    c_0 = 1 + gamma^k*(c_max-1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% can adjust c_max
    % c_0 = 1 + gamma^k*(1.0-1);
    
    sub_f_calc_w
    mmt = beta*mmt + (1-beta)*w;
    bfu(k+1).data = bfu(k).data - mmt;
    
    bfx(k+1).data = f_bfx(bfu(k+1).data);
    err = norm(f_xN_bfu(bfu(k+1).data) - [1-mu+r_lagrange;0;0;0],1);
    % err = norm(f_xN_bfu(bfu(k+1).data) - [1;0.5;0;0],1)
    
    k=k+1;
    % convert_xy_vector
    % if k>10
    %     plot(plot_x, plot_y, 'o', 'MarkerSize', 1, 'Color', 'r');
    %     xlim([1-mu-0.05, 1-mu+0.05]);
    %     ylim([-0.03,0.03]);
    % else
    %     plot(plot_x, plot_y, 'o', 'MarkerSize', 1, 'Color', 'r');
    %     xlim([-0.2, 1.2]);
    %     ylim([-0.5*(1+2*mu), 0.5*(1+2*mu)]);
    % end
    % pause(exp(-0.3*k))
        % else
        % convergence_text = 'n';
        % break
    if isnan(bfu(k).data(1)) == 1
        break
    end

    if err < epsilon
    residue_minimization_solver_kkt
        if residual_l2norm < 10^(-3)
            convergence_text = 'y';
            break
        end
    end
end

if isnan(bfu(k).data(1)) == 1
    convergence_text = 'NaN';
    save("./temp_progress/"+ string(input) + ', ' + convergence_text,"bfu")
else
    save("./temp_progress/"+ string(input) + ', ' + convergence_text + ', ' + string(round(norm(bfu(k).data,1))) ,"bfu")
end

% convert_xy_vector
% plot(plot_x, plot_y, 'o', 'MarkerSize', 2, 'Color', 'k');
% save("./temp_progress/"+ string(input) + ', ' + convergence_text + ', ' + string(round(norm(bfu(k).data,1))) ,"bfu")

% output_0 = impulse;
% output_1 = beta;
% output_2 = c_0;
% output_3 = h;
% output_4 = bfu(k).data;
% output_5 = bfx(k).data;
% output_6 = norm(bfu(k).data,1);
% output_7 = convergence_text;

output_1 = bfu(k).data;
output_2 = norm(bfu(k).data,1);
output_3 = convergence_text;
output_4 = k-1;

% output_1 = 1;
% output_2 = 1;
% output_3 = 1;
% output_4 = 1;
% output_5 = 1;
% output_6 = 1;
% output_7 = 'asdf';